package hypernexusclient

import (
	"github.com/TarsCloud/TarsGo/tars"
	"github.com/wzh200x/hyperNexus/hyperNexusProtocol/dbAgentServerProtocol"
)

// DbAgentServerClient 提供与dbAgentServer服务交互的客户端
type DbAgentServerClient struct {
	Proxy tars.ProxyPrx
}

// Init 初始化DbAgentServerClient
func (c *DbAgentServerClient) Init(comm *tars.Communicator) error {
	cfg := tars.GetServerConfig()
	confs := tars.GetConf()
	// 从配置中获取dbAgentServer的对象名称，如果没有配置则使用默认值
	objName := confs.GetStringWithDef("/tars/application<DBAgentServer>", cfg.App+"."+"DBAgentServer"+".DBAgentServerOperateObj")
	c.Proxy = new(dbAgentServerProtocol.DbAgentServer)
	comm.StringToProxy(objName, c.Proxy)
	return nil
}

// GetClientProxy 获取客户端代理对象
func (c *DbAgentServerClient) GetClientProxy() *dbAgentServerProtocol.DbAgentServer {
	return c.Proxy.(*dbAgentServerProtocol.DbAgentServer)
}

// NewDbAgentServerClient 创建一个新的DbAgentServerClient实例
func NewDbAgentServerClient() *DbAgentServerClient {
	return &DbAgentServerClient{}
}
